import pandas as pd
import codecs


def ReadFile(filePath):

    with codecs.open(filePath, "r") as f:

        return f.read()

def WriteFile(filePath, u, encoding="utf-8"):

    # with codecs.open(filePath,"w",encoding) as f:

    with codecs.open(filePath, "wb") as f:

        f.write(u.encode(encoding, errors="ignore"))

def CSV_2_UTF8(src, dst):

    content = ReadFile(src)

    WriteFile(dst, content, encoding="utf-8")

CSV_2_UTF8(r'C:\Users\AXZQ\Desktop\AUTO\OaProduct\oa.csv', r'C:\Users\AXZQ\Desktop\AUTO\OaProduct\oa_utf8.csv')



oaData=pd.read_csv(r'C:\Users\AXZQ\Desktop\AUTO\OaProduct\oa_utf8.csv')
oaDataNew=oaData[(oaData['主题'].str.contains('开通'))| (oaData['主题'].str.contains('开户'))| (oaData['主题'].str.contains('销户')) | (oaData['主题'].str.contains('取消'))]
tecentData=pd.DataFrame()
tecentData['序号']=0
tecentData['流程编号']=oaDataNew['流程编号']
tecentData['产品名字']=oaDataNew['主题']
tecentData['管理人']=0
tecentData['资金账号']=0
tecentData['信用账户']=0
tecentData['对应柜台']=0
tecentData['申请系统']=0
tecentData['资金账号']=0
tecentData['信用账户']=0
tecentData['申请系统']=0
tecentData['分支机构']=oaDataNew['所属部门']
tecentData['分支机构申请人']=oaDataNew['拟稿人']
tecentData['销户日期']=0
tecentData['开户日期']=oaDataNew['处理时间']
tecentData['开户人']='谭璐'
tecentData.to_csv(r'C:\Users\AXZQ\Desktop\AUTO\OaProduct\tencent.csv')
print('已经生成文件')

